home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
351-375
/
disk_360
/
uucp
/
uucp0.lzh
/
src
/
lib
/
getenv.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-04-04
|
1KB
|
64 lines
/*
* GETENV.C
*
* $Header: Beta:src/uucp/src/lib/RCS/getenv.c,v 1.1 90/02/02 12:08:18 dillon Exp Locker: dillon $
*
* Lattice's screws up.
*
* (C) Copyright 1989-1990 by Matthew Dillon, All Rights Reserved.
*/
#include "protos.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"
Prototype char *gettmpenv(const char *);
Prototype char *getenv(const char *);
char *
gettmpenv(id)
const char *id;
{
static char *buf;
static char *res = NULL;
long fh;
long len;
buf = malloc(strlen(id) + 8);
sprintf(buf, "ENV:%s", id);
fh = Open(buf, 1005);
free(buf);
if (fh) {
Seek(fh, 0L, 1);
len = Seek(fh, 0L, -1);
if (len < 0) {
Close(fh);
return(NULL);
}
if (res)
free(res);
res = malloc(len + 1);
Read(fh, res, len);
Close(fh);
res[len] = 0;
return(res);
}
return(NULL);
}
char *
getenv(id)
const char *id;
{
char *res = gettmpenv(id);
char *perm = NULL;
if (res)
perm = strdup(res);
return(perm);
}